package wells.thread.othertest;

public class ThreadState {
	static Object LOCK = new Object();

	public static void main(String[] args) {
		Thread t = new Thread(() -> {
			int j = 0;
			for (int i = 0; i < 1000000; i++) {
				j++;
			}
			System.out.println("=====" + j);
			synchronized (LOCK) {
				try {
					LOCK.wait();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
			System.out.println("end");

		});
		System.out.println("1."+t.getState());// NEW
		t.start();
		System.out.println("2."+t.getState());// RUNNABLE

		try {
			Thread.sleep(10);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("3."+t.getState());// WAITING
		synchronized (LOCK) {

			LOCK.notifyAll();

		}
		System.out.println("4."+t.getState());// BLOCKED
		try {
			Thread.sleep(10);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("5."+t.getState());// TERMINATED
	}

}
